<?php

//include_once("../../globals.php");
include_once($_SESSION['WEB_ROOT']."/interface/globals.php");
//include_once("/home/saludaun/public_html/bolivar/interface/globals.php");
include_once($GLOBALS["srcdir"] . "/api.inc");
include_once($GLOBALS["srcdir"] . "/options.inc.php");

function procedure_order_report($pid, $encounter, $cols, $id) {
    $cols = 1; // force always 1 column
    $count = 0;
    $query = "SELECT pt.name as Procedure_Order,po.* " .
            "FROM procedure_order as po, procedure_type as pt WHERE " .
            "po.procedure_type_id = pt.procedure_type_id AND po.procedure_order_id = '$id' AND po.activity = '1'";
    
    $data = sqlQuery($query);
    if ($data) {
        print "<table cellpadding='0' cellspacing='0'>\n<tr>\n";
        foreach ($data as $key => $value) {
            if ($key == "procedure_order_id" || $key == "pid" || $key == "user" || $key == "groupname" ||
                    $key == "authorized" || $key == "activity" || $key == "date" ||
                    $key == "provider_id" ||
                    $key == "procedure_type_id" ||
                    $key == "encounter_id" ||
                    $key == "patient_id" ||
                    $key == "date_collected" ||
                    $key == "date_ordered" ||
                    $key == "order_priority" ||
                    $key == "order_status" ||
                    $value == "" || $value == "0" || $value == "0.00") {
                continue;
            }

            $key = ucwords(str_replace("_", " ", $key));
            if ($key == "Order Priority") {
                print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>" .
                        generate_display_field(array('data_type' => '1', 'list_id' => 'ord_priority'), $value) .
                        " &nbsp;</span></td>\n";
            } else if ($key == "Order Status") {
                print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>" .
                        generate_display_field(array('data_type' => '1', 'list_id' => 'ord_status'), $value) .
                        " &nbsp;</span></td>\n";
            } else {
                print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>$value &nbsp;</span></td>\n";
            }
            $count++;
            if ($count == $cols) {
                $count = 0;
                print "</tr>\n<tr>\n";
            }
        }
        print "</tr>\n</table>\n";
    }
}

?>
